package entity;

import lombok.Data;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Data
public class ClassEntity {
    private String id;
    private String specialtyId;
    private String teacherId;
    private String className;
    private String classCode;
    private String grade;

    public static ClassEntity mapToEntity(Map<String, Object> objectMap) {
        ClassEntity classEntity = new ClassEntity();
        classEntity.setId((String) objectMap.get("id"));
        classEntity.setSpecialtyId((String) objectMap.get("specialty_id"));
        classEntity.setTeacherId((String) objectMap.get("teacher_id"));
        classEntity.setClassName((String) objectMap.get("class_name"));
        classEntity.setClassCode((String) objectMap.get("class_code"));
        classEntity.setGrade((String) objectMap.get("grade"));
        return classEntity;
    }

    public static List<ClassEntity> mapListToEntityList(List<Map<String, Object>> objectMapList) {
        return objectMapList.stream().map(ClassEntity::mapToEntity).collect(Collectors.toList());
    }
}
